<!-- 停车 》 电子地图 -->

<template>
  <CommonBody
    hasTree
    :tree="tree"
    :field="TREE_FIELD"
    :param="map_param"
    class="Secure-ParkingMap"
    initRoot
    diy
    @change="toChange"
  >
    <EasyCard title="车位概况" width="30%" height="33%">
      <MyCount />
    </EasyCard>

    <EasyCard width="40%" height="33%">
      <template #title>
        <span>车辆通行走势</span>
        <ParamRadio :param="trend_infoParam" bind="dateType" :dict="trend_DICT.DATE_TYPE" isBtn />
      </template>

      <MyTrend />
    </EasyCard>

    <EasyCard width="30%" height="33%">
      <template #title>
        <span>车辆进出实时消息</span>
        <div>
          <BtnText @click="toRecord">更多<i class="el-icon-d-arrow-right" /></BtnText>
        </div>
      </template>

      <MyRecord />
    </EasyCard>

    <EasyCard width="70%" height="67%">
      <MapView v-if="map_info.id" />
      <MapEmpty v-else />
    </EasyCard>

    <EasyCard title="实时监控" width="30%" height="67%">
      <MyVideo />
    </EasyCard>

    <MyModal />
  </CommonBody>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import mixMap from '@admin/views/Secure/mixMap'
import store from './store'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'ParkingMap',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [mixMap('3', store)],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 监听属性 (深度 deep 首次 immediate)
   */
  watch: {
    /**
     * 监听结构树就绪
     */
    readyTree() {
      // 默认选中根节点
      this.tree.length && this.toChange(this.tree[0])
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 点击切换
     */
    toChange(data) {
      this.map_param.areaId = this.map_infoParam.areaId = data.areaId
      this.map_setList()
      this.map_startInfo()

      this.count_startInfo()
      this.video_startInfo()
    },

    /**
     * 跳转到进出记录
     */
    toRecord() {
      this.$router.push({ name: 'SecureParking_ParkingAccess' })
    },
  },
}
</script>

<style lang="scss">
@import './index.scss';
</style>
